using HCore.IOC.Context.Event;

namespace HCore.Tests.Runtime.ShootingEditor2D.Scripts.Support.CommandQuery
{
    public abstract class CommandQueryEventSender : EventPublisher, ICommandSender, IQuerySender
    {
        /// <summary>
        ///     发送命令
        /// </summary>
        /// <param name="eventObj"></param>
        public void SendCommand(ICommand eventObj)
        {
            PublishEvent(eventObj);
        }

        /// <summary>
        ///     发送查询
        /// </summary>
        /// <param name="query"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T SendQuery<T>(IQuery<T> query)
        {
            PublishEvent(query);
            return query.Result;
        }

        /// <summary>
        ///     发送事件
        /// </summary>
        /// <param name="eventObj"></param>
        public void SendEvent(object eventObj)
        {
            PublishEvent(eventObj);
        }
    }
}